#ifndef PARAMETERS_H
#define PARAMETERS_H

#include <QGraphicsItem>

using namespace std;

class Node;
class Sensor;
class TreeModel;

class Title : public QGraphicsItem{
private:
	
public:
	Title(QGraphicsItem *_source, QString _title, QPointF _pos);
	Title(QGraphicsItem *_source, QString _text, QPointF _pos, double _percentPos);
	void adjust();
	void adjust(QPointF _sourcePos, QPointF _destPos);
	QRectF boundingRect() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void setEnabled(bool b){ enable = b; }
	bool enabled(){ return enable; }
	void setTitle(QString _text){ text = _text; size = QRectF(0, 0, text.length() * 6.5, 20); }
	QString title(){ return text; }
	QPointF positionPath;
	double percentPos;
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *event);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

private:
	QRectF size;
	QGraphicsItem *source;
	QPointF sourcePos;
	bool enable;
	QPointF position;
	bool forPath;
	QPointF sourcePathPos, destPathPos;
	QString text;
};

//-------------------------------------------------------------------------------
class Text : public QObject, public QGraphicsItem
{
	Q_OBJECT

public:
	Text(SceneView *_parentScene, QPointF pos, QString _text);

	QRectF boundingRect() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void initModel();
	QString text;
	void setTitle(QString _text){ text = _text; size = QRectF(0, 0, text.length() * 9.2, 20); }
	QString title(){ return text; }
	void setSelectrable(bool s);
	TreeModel* model;
	double additive_stochastic, additive_deterministic; 
	double multiplicative_stochastic, multiplicative_deterministic;
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *event);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
	QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
	
	QRectF size;
	SceneView *parentScene;
private slots:
	void getModelData(QString name, int posX, int posY);
	void updateTree();
signals:
	void setModelData(QString name, int posX, int posY);
};

#endif